package org.jeecg.config.mybatis;

import lombok.extern.slf4j.Slf4j;

/**
 * description: 租户全局 多租户 tenant_id存储器
 * taskId：
 * <pre>
 * change history:
 * date             defect#             person                comments
 * ---------------------------------------------------------------------
 * 2023/8/2       ********         zhaochaoyue        create file
 * </pre>
 *
 * @author: zhaochaoyue
 * @date: 2023/8/2 16:21
 * @copyright: 2023
 */
@Slf4j
public class TenantContext {

    private static ThreadLocal<String> currentTenant = new ThreadLocal<>();

    public static String getTenant() {
        return currentTenant.get();
    }

    public static void setTenant(String tenant) {
        log.debug(" setting tenant to " + tenant);
        currentTenant.set(tenant);
    }

    public static void clear(){
        currentTenant.remove();
    }
}
